package model;

import java.io.File;
import java.io.Serializable;

/*
 * Stores people introduced in my gui.PersonFormPanel
 * */
public class Product implements Serializable {

	/**
	 * 2013.03.11 - Alejandro Alcaide When implementing the Serializable
	 * interface, it's important to include the serialVerUID because -if used in
	 * different platforms- the class may think the object is not the same and
	 * cause an exception
	 */
	private static final long serialVersionUID = -7056163349221013665L;
	/*
	 * Model variables declaration
	 */
	private static int count = 0;
	private int id;
	/*
	 * Form Variables declaration
	 */
	private String desc;
	
	// constructor for serializing and inserting
	public Product(String desc) {
		this.id = count;
		count++;
		this.desc = desc;
	}

	// constructor for retrieving
	public Product(int id, String desc) {
		// this line uses the upper constructor. it also sets the id, but i'll
		// override
		this(desc);
		// ...overriding
		this.id = id;
	}

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return the desc
	 */
	public String getDesc() {
		return desc;
	}

	/**
	 * @param desc
	 *            the desc to set
	 */
	public void setDesc(String desc) {
		this.desc = desc;
	}

	public String toString() {
		return ("product id #" + getId() + ", desc: " + getDesc());
	}
}
